<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
    <h4 class="modal-title">{{ trans('classes-pages.userclass-title') }}</h4>
    <h6 class="modal-title">{{ $sClassName }}</h6>
</div>
<div class="portlet modal-body portlet-body form">
    <div class="table-responsive">
        <table class="table table-hover">
            <thead>
                <tr>
                    <th>{{ trans('user.userid'      ) }}</th>
                    <th>{{ trans('user.username'    ) }}</th>
                    <th>{{ trans('user.birthday'    ) }}</th>
                    <th>{{ trans('user.phone'       ) }}</th>
                    <th>{{ trans('system.actions'   ) }}</th>
                </tr>
            </thead>
            <tbody>
                @foreach( $Users as $oUser)
                <tr>
                    <td>{{{ $oUser->id                                  }}}</td>
                    <td>{{{ $oUser->username                            }}}</td>
                    <td>{{{ CNamHoa::ConvertDate($oUser->birthday)   }}}</td>
                    <td>{{{ $oUser->phone                               }}}</td>
                    <td>
                        <button class="btn btn-xs red btn-remove-userclass {{ CNamHoa::getHideClass('class-remove-user', ['addClass' => 'hide']) }}" data-user-id="{{ $oUser->id }}"><i class="fa fa-trash-o"></i> {{ trans('system.button.delete') }}</button>
                    </td>
                </tr>
                @endforeach
            </tbody>
        </table>
    </div>
</div>
<div class="modal-footer">
    <button type="button" class="btn default" data-dismiss="modal">{{ trans('system.button.cancel') }}</button>
</div>
<script type="text/javascript">
    $('.btn-remove-userclass').click(function () {
        $(this).hide().parent().append('<img src="{{ asset("assets/admin/layout/img/loading.gif")}}">');

        $.ajax({
            url: '{{ route("class-remove-user") }}',
            type: 'post',
            data: {
                'class_id': '{{ $ClassInfo->id }}',
                'user_id':$(this).attr('data-user-id')
            },
            dataType: 'json'
        }) .done(function(response) {
            if (response.status == 200) {
                $('button.btn-remove-userclass[data-user-id="'+response.user_id+'"]').parent().parent().remove();
            }
            else {
                $('button.btn-remove-userclass[data-user-id="'+response.user_id+'"]').show().parent().find('img').remove();
            }
        });
    });
</script>